From: Maciej Trela <maciej.trela [at] intel.com>
Support reading layout and chunk size from mdstat.
It is needed for external reshape with layout or chunk size changes.
Signed-off-by: Maciej Trela <maciej.trela [at] intel.com>
---
mdadm.h | 1 +
mdstat.c | 11 +++++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/mdadm.h b/mdadm.h
index 9889c60..e5e56fe 100644
--- a/mdadm.h
+++ b/mdadm.h
[at] [at] -348,6 +348,7 [at] [at] struct mdstat_ent {
int resync; /* 1 if resync, 0 if recovery */
int devcnt;
int raid_disks;
+ int layout;
int chunk_size;
char * metadata_version;
struct mdstat_ent *next;
diff --git a/mdstat.c b/mdstat.c
index af1cae4..287ed48 100644
--- a/mdstat.c
+++ b/mdstat.c
[at] [at] -118,7 +118,7 [at] [at] struct mdstat_ent *mdstat_read(int hold, int start)
end = &all;
for (; (line = conf_line(f)) ; free_line(line)) {
struct mdstat_ent *ent;
- char *w;
+ char *w, *prev = NULL;
int devnum;
int in_devs = 0;
char *ep;
[at] [at] -163,7 +163,7 [at] [at] struct mdstat_ent *mdstat_read(int hold, int start)
ent->dev = strdup(line);
ent->devnum = devnum;
- for (w=dl_next(line); w!= line ; w=dl_next(w)) {
+ for (w = dl_next(line); w != line ; prev = w, w = dl_next(w)) {
int l = strlen(w);
char *eq;
if (strcmp(w, "active")==0)
[at] [at] -220,6 +220,13 [at] [at] struct mdstat_ent *mdstat_read(int hold, int start)
w[0] <= '9' &&
w[l-1] == '%') {
ent->percent = atoi(w);
+ } else if (strcmp(w, "algorithm") == 0 &&
+ dl_next(w) != line) {
+ w = dl_next(w);
+ ent->layout = atoi(w);
+ } else if (strncmp(w, "chunk", 5) == 0 &&
+ prev != NULL) {
+ ent->chunk_size = atoi(prev) * 1024;
}
}
if (insert_here && (*insert_here)) {
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
